home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The X-Philes (2nd Revision)
/
The X-Philes Number 1 (1995).iso
/
xphiles
/
hp48_2
/
chasm01.sha
/
sample.ch
< prev
Wrap
Text File
|
1995-03-23
|
2KB
|
72 lines
/ This is a sample chasm file. It doesn't do an awful lot, but makes
/ a good example. Keep in mind that this is pretty much of a hack.
/ The only key used by the program is "+".
/ Registers used:
/ V0 - scratch
/ V1 - keypress flag
/ V2 - key comparison
/ V3 - sprite x
/ V4 - sprite y
/ V5 - sad/smile flag
/ V6 - scratch
/ V7 - scratch
jmp start / jump over the data
data "By Steve Scherf" / this shows up for all to see
start:
cld / blank the screen
mov 0, V1 / initialize keypress flag
mov 0xF, V2 / this is the plus key
mov 32, V3 / initialize x coord
mov 16, V4 / initialize y coord
mov 0, V5 / initialize smiley flag
mov sprite, I / set pointer to sprite
dsp 6, V3, V4 / display the sprite
loop:
jsr get_key / check for keyboard input
mov dtimer, V0 / copy dtimer to V0
sne 0, V0 / is it time to move sprite?
jsr move_sprite / do so if it is time
jmp loop / go back to top
/ don't fall through here
get_key:
mov 0, V7 / clear V7
snp V2 / check for the "+" key
mov 1, V7 / set V7 to true if pressed
mov V1, V6 / set V6 to old value of keypress flag
mov V7, V1 / set keypress flag accordingly
seq 1, V7 / is the key pressed?
ret / return if not
sne 1, V6 / if V6 is true, key has not been lifted
ret / return if not lifted
mov 1, V6
mov V6, stimer / beep for 1/60th second
mov 1, V6
xor V6, V5 / toggle smile/sad flag
dsp 6, V3, V4 / clear the old sprite
mov sprite, I / point I to the new sprite
mov 6, V6
seq 0, V5 / is this the second sprite?
add V6, I / point I to the second sprite
dsp 6, V3, V4 / display the new sprite
ret
move_sprite:
dsp 6, V3, V4 / clear the old sprite
add 1, V3 / compute new coords
add 255, V4 / this is the same as subtracting 1
dsp 6, V3, V4 / display the sprite at new coords
mov 15, V0 / we can only set timer from a register
mov V0, dtimer / set timer for 1/4 second
ret
sprite:
data 0x66, 0x66, 0x00, 0x00, 0x42, 0x3C / smiley sprite
data 0x66, 0x66, 0x00, 0x00, 0x3C, 0x42 / sad sprite